From d4224cd325932674cb55c8541165c40b0c052af6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 7 Jun 2011 11:05:50 -0400 Subject: [PATCH] GtkGrid: Fix a size allocation problem We need pay attention the the request mode when doing size allocation. The code was using request mode for requisition, but orientation for allocation. Also add a reftest that exhibits the issue, courtesy of Benjamin Otte. --- gtk/gtkgrid.c | 14 ++++++++---- tests/reftests/Makefile.am | 2 ++ tests/reftests/grid-wfh.ref.ui | 40 +++++++++++++++++++++++++++++++++ tests/reftests/grid-wfh.ui | 41 ++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 tests/reftests/grid-wfh.ref.ui create mode 100644 tests/reftests/grid-wfh.ui diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index e1c56f948f..88fe59de3a 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -1231,6 +1231,7 @@ gtk_grid_size_allocate (GtkWidget *widget, GtkGridPrivate *priv = grid->priv; GtkGridRequest request; GtkGridLines *lines; + GtkOrientation orientation; if (priv->children == NULL) { @@ -1250,10 +1251,15 @@ gtk_grid_size_allocate (GtkWidget *widget, gtk_widget_set_allocation (widget, allocation); - gtk_grid_request_run (&request, 1 - priv->orientation, FALSE); - gtk_grid_request_allocate (&request, 1 - priv->orientation, GET_SIZE (allocation, 1 - priv->orientation)); - gtk_grid_request_run (&request, priv->orientation, TRUE); - gtk_grid_request_allocate (&request, priv->orientation, GET_SIZE (allocation, priv->orientation)); + if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT) + orientation = GTK_ORIENTATION_HORIZONTAL; + else + orientation = GTK_ORIENTATION_VERTICAL; + + gtk_grid_request_run (&request, 1 - orientation, FALSE); + gtk_grid_request_allocate (&request, 1 - orientation, GET_SIZE (allocation, 1 - orientation)); + gtk_grid_request_run (&request, orientation, TRUE); + gtk_grid_request_allocate (&request, orientation, GET_SIZE (allocation, orientation)); gtk_grid_request_position (&request, 0); gtk_grid_request_position (&request, 1); diff --git a/tests/reftests/Makefile.am b/tests/reftests/Makefile.am index 761d29490d..18fead95f4 100644 --- a/tests/reftests/Makefile.am +++ b/tests/reftests/Makefile.am @@ -69,6 +69,8 @@ EXTRA_DIST += \ grid-expand.css \ grid-expand.ref.ui \ grid-expand.ui \ + grid-wfh.ui \ + grid-wfh.ref.ui \ grid-homogeneous.css \ grid-homogeneous.ref.ui \ grid-homogeneous.ui \ diff --git a/tests/reftests/grid-wfh.ref.ui b/tests/reftests/grid-wfh.ref.ui new file mode 100644 index 0000000000..f01a7d7ea0 --- /dev/null +++ b/tests/reftests/grid-wfh.ref.ui @@ -0,0 +1,40 @@ + + + + + False + popup + + + True + False + + + True + False + GNOME is awesome! + + + 0 + 0 + 1 + 1 + + + + + True + False + GNOME is awesome! + + + 0 + 1 + 1 + 1 + + + + + + diff --git a/tests/reftests/grid-wfh.ui b/tests/reftests/grid-wfh.ui new file mode 100644 index 0000000000..8b252eabe9 --- /dev/null +++ b/tests/reftests/grid-wfh.ui @@ -0,0 +1,41 @@ + + + + + False + popup + + + True + False + + + True + False + GNOME is awesome! + True + + + 0 + 0 + 1 + 1 + + + + + True + False + GNOME is awesome! + + + 0 + 1 + 1 + 1 + + + + + + -- 2.30.2